#include "collectionimage.h"

#include <string.h>
#include <new>

CollectionImage::CollectionImage()
{
	_fileName = NULL;
}

CollectionImage::CollectionImage( const CollectionImage &img )
{
	_thumbnail = img.thumbnail();
	_fileName = new wchar_t[ wcslen( img._fileName )+2 ];
	wcscpy( _fileName, img._fileName );
}

CollectionImage::~CollectionImage()
{
	if( _fileName )
		delete _fileName;
}

CollectionImage& CollectionImage::operator =( const CollectionImage &img )
{
	//Destruct and copy construct this object in place.
	this->~CollectionImage();
	new (this) CollectionImage( img );
	return *this;
}

wchar_t* CollectionImage::fileName() const
{
	return _fileName;
}

void CollectionImage::setFileName( const wchar_t *fileName )
{
	assert( fileName );

	//Delete the old file name.
	if( _fileName )
		delete _fileName;

	//Set the new file name.
	_fileName = new wchar_t[ wcslen( fileName )+2 ];
	wcscpy( _fileName, fileName );
}

Ref<DIB> CollectionImage::thumbnail() const
{
	return _thumbnail;
}

void CollectionImage::setThumbnail( Ref<DIB> thumbnail )
{
	_thumbnail = thumbnail;
}
